package com.hxzy.shop.controller;

import com.github.pagehelper.PageInfo;
import com.hxzy.shop.common.dto.merchant.req.AnnouncementMerchantListReq;
import com.hxzy.shop.common.dto.merchant.resp.AnnouncementDetailResp;
import com.hxzy.shop.dto.req.AnnouncementIdReq;
import com.hxzy.shop.dto.resp.AnnouncementClassificationListResp;
import com.hxzy.shop.dto.resp.AnnouncementMerchantDetailResp;
import com.hxzy.shop.service.AnnouncementService;
import com.hxzy.shop.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 功能描述: 公告管理
 *
 * @author tonneyyy
 */
@RestController
@Api(tags = "公告管理")
@RequestMapping("/announcement")
public class AnnouncementController {

    /**
     * 服务对象
     */
    @Resource
    private AnnouncementService announcementService;

    /*******************商户相关***********************/
//    @ApiOperation("公告 查看")
//    @PostMapping("/announcementLook/{id}")
//    public Result<AnnouncementDetailResp> announcementLook(@PathVariable(value = "id") Long announcementId){
//        return Result.success(announcementService.announcementLook(announcementId));
//    }

    @ApiOperation("公告 查看")
    @PostMapping("/announcementLook")
    public Result<AnnouncementDetailResp> announcementLook(@RequestBody AnnouncementIdReq req){
        return Result.success(announcementService.announcementLook(req));
    }
    @ApiOperation("公告 获取商户当前未看公告条数")
    @PostMapping("/getAnnouncementNotLook")
    public Result<Integer> getAnnouncementNotLook(){
        System.out.println("查询了消息么");
        return Result.success(announcementService.getAnnouncementNotLook());
    }

    @ApiOperation("商户获得公告")
    @PostMapping("/getAnnouncementMerchant")
    public Result<PageInfo<AnnouncementMerchantDetailResp>> getAnnouncementMerchant(@RequestBody AnnouncementMerchantListReq req){
        return Result.success(announcementService.getAnnouncementMerchant(req));
    }

    @ApiOperation("商户获得公告分类")
    @PostMapping("/getAnnouncementClassification/{isLook}")
    public Result<List<AnnouncementClassificationListResp>> getAnnouncementClassification(@PathVariable("isLook") Integer isLook){
        return Result.success(announcementService.getAnnouncementClassification(isLook));
    }
}
